package com.itheima.d2_buffered_stream;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;

/*
    目标：观察原始流和缓冲流的性能。
 */
public class TimeTest4 {
    public static void main(String[] args) throws Exception {
        long start = System.currentTimeMillis();
        copy1();
        long end = System.currentTimeMillis();
        System.out.println(end - start);
    }
    public static void copy1() throws Exception {
        FileReader fr = new FileReader("bbb.txt");
        char[] buf = new char[1024];
        int len;
        while ((len = fr.read(buf)) != -1) {
            System.out.print(new String(buf, 0, len));
        }
        fr.close();
    }
    public static void copy2() throws Exception {
        BufferedReader br = new BufferedReader(new FileReader("bbb.txt"));
        String line;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
        }
        br.close();
    }
}










